using System.ComponentModel.DataAnnotations;

namespace DaoHang.Models
{
    /// <summary>
    /// AI配置模型，用于存储大模型相关配置
    /// </summary>
    public class AIConfig
    {
        /// <summary>
        /// 配置ID，主键
        /// </summary>
        [Key]
        public int Id { get; set; }

        /// <summary>
        /// API密钥
        /// </summary>
        [Required(ErrorMessage = "API密钥不能为空")]
        [MaxLength(500, ErrorMessage = "API密钥不能超过500个字符")]
        public string ApiKey { get; set; } = string.Empty;

        /// <summary>
        /// API地址
        /// </summary>
        [Required(ErrorMessage = "API地址不能为空")]
        [MaxLength(500, ErrorMessage = "API地址不能超过500个字符")]
        [Url(ErrorMessage = "请输入有效的API地址")]
        public string ApiUrl { get; set; } = string.Empty;

        /// <summary>
        /// 模型名称
        /// </summary>
        [Required(ErrorMessage = "模型名称不能为空")]
        [MaxLength(200, ErrorMessage = "模型名称不能超过200个字符")]
        public string ModelName { get; set; } = string.Empty;

        /// <summary>
        /// 模型提供商（如：阿里云、OpenAI等）
        /// </summary>
        [MaxLength(100, ErrorMessage = "模型提供商不能超过100个字符")]
        public string Provider { get; set; } = "阿里云百炼";

        /// <summary>
        /// 是否启用AI功能
        /// </summary>
        public bool IsEnabled { get; set; } = true;

        /// <summary>
        /// 请求超时时间（秒）
        /// </summary>
        [Range(5, 300, ErrorMessage = "超时时间必须在5-300秒之间")]
        public int TimeoutSeconds { get; set; } = 30;

        /// <summary>
        /// 最大重试次数
        /// </summary>
        [Range(0, 5, ErrorMessage = "重试次数必须在0-5次之间")]
        public int MaxRetries { get; set; } = 2;

        /// <summary>
        /// 温度参数（控制生成文本的随机性）
        /// </summary>
        [Range(0.0, 2.0, ErrorMessage = "温度参数必须在0.0-2.0之间")]
        public double Temperature { get; set; } = 0.7;

        /// <summary>
        /// 最大生成长度
        /// </summary>
        [Range(100, 4000, ErrorMessage = "最大生成长度必须在100-4000之间")]
        public int MaxTokens { get; set; } = 1000;

        /// <summary>
        /// 配置描述
        /// </summary>
        [MaxLength(500, ErrorMessage = "配置描述不能超过500个字符")]
        public string? Description { get; set; }

        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime CreateTime { get; set; } = DateTime.Now;

        /// <summary>
        /// 更新时间
        /// </summary>
        public DateTime UpdateTime { get; set; } = DateTime.Now;

        /// <summary>
        /// 最后测试时间
        /// </summary>
        public DateTime? LastTestTime { get; set; }

        /// <summary>
        /// 测试状态（成功/失败）
        /// </summary>
        public bool? TestStatus { get; set; }

        /// <summary>
        /// 测试错误信息
        /// </summary>
        [MaxLength(1000, ErrorMessage = "测试错误信息不能超过1000个字符")]
        public string? TestErrorMessage { get; set; }
    }
} 